// 泛型
// 1. 函数

export function ide<T>(params: T): T {
	return params
}

ide<number>(123)

ide<string>('1231231')



// 2. 接口
interface Person<T> {
	name: string
	age: T
	sex: string
}


const o: Person<number> = {
	name: '真敢',
	age: 18,
	sex: '男'
}


const o1: Person<string> = {
	name: '真敢',
	age: "18",
	sex: '男'
}

console.log(o, o1);

// 3. 类

class Animal<T = string, U = string>{
	name: T
	age: U
	constructor(name: T, age: U) {
		this.name = name
		this.age = age
	}
}


const cat = new Animal('小猫', '2')
const dog = new Animal<string, number>('小猫', 3)